package com.matthicks.macrobot;

import java.io.File;

public class Test {
	public static void main(String[] args) throws Exception {
		File directory = new File("//bluemeanie.imirus.local/ftp/imirus - ESPN/espn/2003");
		for (File issue : directory.listFiles()) {
			if (issue.isDirectory()) {
//				System.out.println("Issue: " + issue.getAbsolutePath());
				File layout = new File(issue, "Layouts");
				if (layout.isDirectory()) {
//					System.out.println("Layout: " + layout.getAbsolutePath());
					if (!hasQuarkFiles(layout)) {
						System.out.println("No quark files! " + layout.getAbsolutePath());
						for (File f : layout.listFiles()) {
							if (f.getName().indexOf('.') == -1) {
								if (f.renameTo(new File(layout, f.getName() + ".lo"))) {
//									System.out.println("\tRenamed: " + f.getName());
								} else {
									System.err.println("Could not rename: " + f.getAbsolutePath());
								}
							}
						}
					}
				}
			}
		}
	}
	
	public static final boolean hasQuarkFiles(File directory) {
		for (File f : directory.listFiles()) {
			if (f.getName().toLowerCase().endsWith(".lo")) {
				return true;
			}
		}
		return false;
	}
}